<div id ="avgRatings">
Average Class ratings for <?php echo $this->data; ?>
</div>
<div id ="holder"></div>
<?php 
$count = null;
$this->dojo()->enable();
foreach($this->paginator as $list) {
	$grade = null;
if ($list['final'] == 1){
	$grade = "A/A-";
}
else if($list['final'] == 2){
	$grade = "B+/B";
}
else if ($list['final'] == 3){
	 $grade = "B-/C";
}
else if ($list['final'] == 4){
	$grade  = "C-/D";
}
else {
	$grade = "F";
}
$count = $list['recount'];
$dat = "Number of respondents :" .$list['recount'] ."<br>"
 ."Grade :" .$grade . "<br>"
 ."Difficulty: " .$list['diff'] . "<br>"
 ."Time : "  .$list['time'] . "<br>"
 ."Usefulness of textbook:  ".$list['use_rating'] . "<br>"
 ."Instructor rating:  ".$list['i_rating'] . "<br>";
}

$legend= "Difficulty:" ."1-- Very Easy, 2-- Easy, 3 -- Moderate, 4--Difficult, 5-- Very Difficult<br>"
 ."Time Burden :" ."1-- Very Light, 2-- Light, 3-- Average, 4-- Heavy 5-- Very Heavy<br>"
 ."Instructor Rating :" ."1-- Very Poor, 2-- Poor, 3-- Average, 4-- Good, 5-- Excellent<br>"
 ."Usefulness of textbook:"  ."1-- Very Poor, 2-- Poor, 3-- Moderate, 4-- Useful, 5-- Very Useful";
?>
<?php if ($count == 0){
$url = $this->url(array("module"=>"community", "controller"=>"ratecourse", "action"=>"rate", "course"=>$this->course, "semester"=>$this->sem, "year"=>$this->year, "course_no"=>$this->courseNo));
$msg = "No data exists for this course yet<br><a href =$url>Be the first to rate this class!</a>";
}else{
$msg="Plot of Average ratings" ;
}?>
<p></p>
<h3><?php echo $msg;?></h3>
<script type="text/javascript">

dojo.require("dojox.charting.Chart2D");
dojo.require("dijit.TitlePane");

makeCharts = function(){

        var chart1 = new dojox.charting.Chart2D("simplechart");
        chart1.addPlot("default", {type: "Columns", gap: 5});
        chart1.addAxis("y", {vertical: true, min: 0, max: 5,  stroke: "black"});
        chart1.addAxis("x", {
            labels: [{value: 1, text: "Difficulty" }, {value: 2, text: "Time Burden"},
                    {value: 3, text: "Usefulness Textbook"}, {value: 4, text: "Instructor Rating"}]
            });   chart1.addSeries("Series 1", [<?php echo $list['diff']; ?>, <?php echo $list['time'];?>, <?php echo $list['use_rating'];?>, <?php echo $list['i_rating'];?>],{stroke: {color: "black", width: 1.5}, 
        fill: "red"}        
        );
        chart1.render();
       
};


add = function() {

    legend = new dijit.TitlePane({
        title: "Rating Legend",
        content: "<?php echo $legend; ?>", 
        open: false
    });


    com = new dijit.TitlePane({
        title: "<?php echo $this->name;?>",
        content: "<?php echo $dat; ?>", 
        style: "width:300px",  
        open: false
    });
    
    dojo.byId("holder").appendChild(com.domNode);
    dojo.byId("legend").appendChild(legend.domNode);
};
dojo.addOnLoad(add);
dojo.addOnLoad(makeCharts);

</script>

<div id="simplechart" align = "left" style="width: 600px; height: 200px;"></div>

<div id="legend"></div>